package b2.widget
{
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.filters.BitmapFilterQuality;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	public class PopMessage extends Sprite
	{
		public function PopMessage(msg:String, color:Object = 0x00FF00, textSize:int = 24)
		{
			super();
			
			//具体信息
			var tipText:TextField = new TextField();
			tipText.selectable = false;
        	tipText.autoSize = TextFieldAutoSize.LEFT;
        	//tipText.width = textWidth;
			
        	var textFormat:TextFormat;
        	textFormat = new TextFormat("微软雅黑", textSize, color, true);
        	tipText.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			tipText.defaultTextFormat = textFormat;
			tipText.text = msg;
			addChild(tipText);
			TweenLite.delayedCall(1.2, disappear);
		}
		
		//消失
		public function disappear():void
		{
			TweenLite.to(this, 1, {x:this.x, y:this.y - 30, alpha:0, onComplete:close});
		}
		
		public function close():void
        {
        	if (this.parent != null)
        	{
        		this.parent.removeChild(this);
        	}
        }

	}
}